package com.stone.persistent.recyclerview.widget;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

import androidx.annotation.Nullable;

import com.stone.persistent.recyclerview.extensions.ContextExtensions;



public class ProgressImageView extends ImageView {
    private CircularProgressDrawable drawable;

    public  CircularProgressDrawable getDrawable() {
        return this.drawable;
    }

    public  void setDrawable( CircularProgressDrawable var1) {
        this.drawable = var1;
    }

    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        this.drawable.start();
    }

    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        this.drawable.stop();
    }

    public ProgressImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.drawable = new CircularProgressDrawable(context);
        this.drawable.setStrokeWidth(ContextExtensions.dp2px(context, 2.0F));
        this.drawable.setStrokeCap(Paint.Cap.ROUND);
        this.drawable.setArrowEnabled(true);
        this.drawable.setColorSchemeColors(Color.WHITE);
        this.setImageDrawable((Drawable)this.drawable);
    }


    public ProgressImageView( Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

}
